(function() {
	var tabObj =  null; // table控件

	window.nameLink = function (cellData, dom) {
		var id = dom.children().eq(0).html(),
			url = keter.reqRoot+'/view/'+id;
		return '<a href="'+url+'">' + cellData + '</a>';
	};
	
	window.getSenderName = function (cellData, dom, data) {
	    console.info(data);
		return data.name;
	};
	
	window.operator = function (cellData, dom) {
		var id = dom.children().eq(0).html();
		return '<a href="#" onclick="deleteMessage('+id+');" >删除</a>';
	};
	
	window.deleteMessage = function(id){
		if(window.confirm('确定删除该消息？')){
		 $.ajax({
				url: keter.reqRoot + '/delete/'+id,
				contentType:'application/json',
				type:'POST',
				context: document.body
			}).done(function(data){
				success(data,true);
			});
		 return true;
		} else {
			return false;
		}
	};

	
	var get = function () {
		$.ajax({
			url: keter.reqRoot + '/getAll',
			context: document.body
		}).done(function(data) {
			tabObj = $('.kt_table').createTable({
				data : data
			});
		});
	};

	var main = function () {
		get();
	};

	return main();
})();
